package cn.edu.scau.dormitory_management_system.module.examine.controller;

import cn.edu.scau.dormitory_management_system.constant.Consts;
import cn.edu.scau.dormitory_management_system.module.examine.entity.FlowNodeEntity;
import cn.edu.scau.dormitory_management_system.module.examine.service.FlowNodeService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ：Vizzk
 * @description：TODO
 * @date ：2021/8/18 20:24
 */
@RestController
@RequestMapping("/admin/flowNode")
public class FlowNodeController {

    @Autowired
    private FlowNodeService flowNodeService;

    @GetMapping("/listFlowNodesByFlowId")
    public Object listFlowNodesByFlowId(Integer flowId){
        JSONObject jsonObject = new JSONObject();
        try {
            List<FlowNodeEntity> nodes = flowNodeService.listFlowNodesByFlowId(flowId);
            jsonObject.put(Consts.CODE, 200);
            jsonObject.put(Consts.MSG, "查询审核流程成功");
            jsonObject.put("nodes", nodes);
        }
        catch (Exception e){
            jsonObject.put(Consts.CODE, 0);
            jsonObject.put(Consts.MSG, "获取审核流程失败");
        }
        return jsonObject;
    }
}
